<<<<<<< HEAD
<template>
  <div class="aMap_wrap">
    <el-amap class="map" vid="aMap" :zoom="zoom" :events="events"></el-amap>
  </div>
</template>

<script>
import { AMapManger, lazyAMapApiLoaderInstance } from "vue-amap";
export default {
  data() {
    return {
      map: null,
      zoom: 15,
      events: {}
    };
  },
  mounted() {
    lazyAMapApiLoaderInstance.load().then(() => {
      this.map = new AMap.Map("aMap", {
        center: ["116.404765", "39.918052"],
        zoom: this.zoom
      });
    });
  }
};
</script>

<style lang="scss" scoped>
.aMap_wrap {
  width: 100%;
  height: 100%;
  // background-color: aqua;
  .map {
    width: 100%;
    height: 100%;
  }
}
=======
<template>
  <div class="aMap_wrap">
    <el-amap class="map" vid="aMap" :zoom="zoom" :events="events"></el-amap>
  </div>
</template>

<script>
import { AMapManger, lazyAMapApiLoaderInstance } from "vue-amap";
import { getLngLat } from "./common";
import { addressSetMapCenter } from "./location";
import { amapSetMarker, claenMarker } from "./marker";
export default {
  props: {
    options: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      map: null,
      zoom: 15,
      lnglat: {},
      events: {},
    };
  },
  mounted() {
    lazyAMapApiLoaderInstance.load().then((e) => {
      this.mapCreate();
      this.map.on("click", (e) => {
        const lngLatData = getLngLat(e);
        this.lnglat = lngLatData;
        this.$emit("callback", {
          function: "getLngLat",
          data: lngLatData,
        });
        this.setMarker();
      });
    });
  },
  methods: {
    // 创建地图
    mapCreate() {
      this.map = new AMap.Map("aMap", {
        center: ["116.404765", "39.918052"],
        zoom: this.zoom,
      });
      this.map.on("complete", () => {
        this.mapLoad();
      });
    },
    mapLoad() {
      if (this.options.mapload) {
        this.$emit("callback", {
          function: "mapLoad",
        });
      }
    },
    // 销毁地图
    mapDestroy() {
      this.map && this.map.destroy();
    },
    setMapCenter(value) {
      addressSetMapCenter(value, this.map);
    },
    setMarker(lnglat) {
      amapSetMarker(lnglat || this.lnglat, this.map);
    },
  },
};
</script>

<style lang="scss" scoped>
.aMap_wrap {
  width: 100%;
  height: 100%;
  // background-color: aqua;
  .map {
    width: 100%;
    height: 100%;
  }
}
>>>>>>> 103eb3ad054c9ab96a8d469a8b9b68e43ae3ea0a
</style>